package util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**
 * 58帖子转化公共方法
 * Created by 6v on 2018/6/27.
 */
public class WubaInfoUtil {


    /**
     *58 para 转化成map
     * @param str
     * @return
     */
    public static Map<String, String> str2Map(String str) {
        Map<String, String> map = new HashMap<String, String>();

        try {
            JSONArray jsonArr = JSON.parseArray(str.trim());
            for (int i = 0; i < jsonArr.size(); i++) {
                JSONObject jsonObject = jsonArr.getJSONObject(i);
                String key = jsonObject.getString("I");
                String value = jsonObject.getString("V");
                map.put(key, value);
            }
        } catch (Exception e) {
//            e.printStackTrace();
        }

        return map;
    }



}
